<template>
	<view>
		<!-- 头部搜索框 -->
		<search :placeholder="$t('public.warehousePositionCode')" />
		<!-- 搜索无记录 -->
		<zy-empty v-if="positionInfoList.length==0"></zy-empty>
		<!-- 查询表单 -->
			<positionInfoList :positionInfoList="positionInfoList" v-else></positionInfoList>
	</view>
</template>

<script>
	import {
		positionGetEntityByCode
	} from "@/api/homepage.js"
	import positionInfoList from './InfoList/positionInfoList.vue'
	export default {
		components: {
			positionInfoList
		},
		data() {
			return {
				position: '',
				positionInfoList: [],
			}
		},
		onPullDownRefresh() {
			setTimeout(function() {
				uni.redirectTo({
					url: "/pages/HomePage/StoreManagement/AccessoryManagement/InStorage/positionList"
				})
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onLoad() {
			//PDA扫描
			var _this = this
			uni.$on('scancodedate', function(data) {
				_this.searchList(data.code)
			})
		},
		onUnload() {
			// 移除监听事件      
			uni.$off('scancodedate')
		},
		methods: {
			searchList(e) {
				positionGetEntityByCode({
					code: e
				}).then((res) => {
					console.log(res)
					this.positionInfoList = []
					if (res.code == 0) {
						this.positionInfoArr = res.data.storageList
						for (var i = 0; i < this.positionInfoArr.length; i++) {
							let positionInfoGood = {
								warehouseStorageId: this.positionInfoArr[i].id,
								warehousePositionId: this.positionInfoArr[i].warehousePositionId,
								stock: this.positionInfoArr[i].stock,
								createTime: this.positionInfoArr[i].createTime,
								code: this.positionInfoArr[i].code,
							}
							this.positionInfoList.push(positionInfoGood)
						}
					} else {
						uni.$u.toast(res.message)
					}
				})
			},
		}
	}
</script>
<style lang="scss" scoped>
</style>
